package com.mls.guardian.container;

import com.mls.guardian.appst.AppController;
import com.mls.guardian.config.AppSTConfig;
import com.mls.guardian.config.ProjectConfig;
import com.mls.guardian.dataobj.ProcessMessage;
import com.mls.guardian.em.ContainerRole;
import com.mls.guardian.protocol.body.AppRestartBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jl on 15/9/9.
 */
public abstract class BaseContainer {
    private static final Logger log = LoggerFactory.getLogger(BaseContainer.class);
    protected AppController appController;
    protected List<ProjectConfig> projectObjList = new ArrayList();
    protected AppSTConfig appStConfig = new AppSTConfig();
    protected ContainerRole role;

    public BaseContainer(AppSTConfig appStConfig) {
        this.appStConfig = appStConfig;
    }

    public void setAppController(AppController appController) {
        this.appController = appController;
    }

    public AppController getAppController() {
        return appController;
    }

    public ContainerRole getRole() {
        return role;
    }

    public AppRestartBody restartApp(String projectName, List<ProcessMessage> list, String versionTag) throws Exception {

        return appController.restartApp(projectName, list, versionTag);
    }

    public abstract void startup() throws Exception;

    public abstract void shutdown();

}
